package com.yanqu.xiuxian.config.elementalbonds;

import com.yanqu.xiuxian.config.annotations.ConfigFieldAnnotation;
import com.yanqu.xiuxian.config.annotations.ConfigFileAnnotation;
import com.yanqu.xiuxian.config.common.range.IntRange;
import com.yanqu.xiuxian.config.common.weight.WeightConfig;
import com.yanqu.xiuxian.config.utils.excel.StringUtils;

import java.util.List;

//夺魁积分表
@ConfigFileAnnotation(fileName = "ElementalBondsScore")
public class ElementalBondsScoreConfig {
    private int id;
    private int season;
    private int bigTitle;
    private int title;
    private String name;
    private int points;
    @ConfigFieldAnnotation(filedName = "score", parseMethod = "parseScore")
    private List<Long> score;
    private int levelProtect;
    private String reward;
    @ConfigFieldAnnotation(filedName = "match", parseMethod = "parseMatchRange")
    private List<Integer> matchRangeList;
    @ConfigFieldAnnotation(filedName = "cardQuality", parseMethod = "parseCardQuality")
    private WeightConfig<ElementalBondsCardWeight> cardPullWeight;
    private int scoreRate;

    IntRange qualityRange;
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getSeason() {
        return season;
    }

    public void setSeason(int season) {
        this.season = season;
    }

    public int getBigTitle() {
        return bigTitle;
    }

    public void setBigTitle(int bigTitle) {
        this.bigTitle = bigTitle;
    }

    public int getTitle() {
        return title;
    }

    public void setTitle(int title) {
        this.title = title;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPoints() {
        return points;
    }

    public void setPoints(int points) {
        this.points = points;
    }

    public String getReward() {
        return reward;
    }

    public void setReward(String reward) {
        this.reward = reward;
    }

    public List<Long> getScore() {
        return score;
    }

    public void setScore(List<Long> score) {
        this.score = score;
    }

    public int getLevelProtect() {
        return levelProtect;
    }

    public void setLevelProtect(int levelProtect) {
        this.levelProtect = levelProtect;
    }

    public List<Integer> getMatchRangeList() {
        return matchRangeList;
    }

    public void setMatchRangeList(List<Integer> matchRangeList) {
        this.matchRangeList = matchRangeList;
    }

    public void parseMatchRange(String matchRange){
        this.matchRangeList = StringUtils.stringToIntegerList(matchRange,"\\|");
    }

    public IntRange getQualityRange() {
        return qualityRange;
    }

    public void parseCardQuality(String cardQuality) {
        WeightConfig<ElementalBondsCardWeight> tmpList = new WeightConfig<>();
        String[] cardQualityList = cardQuality.split("\\|");
        int min = Integer.MAX_VALUE;
        int max = 0;
        for (String s : cardQualityList) {
            String[] split = s.split("=");
            int quality = Integer.parseInt(split[0]);
            int weight = Integer.parseInt(split[1]);
            tmpList.add(new ElementalBondsCardWeight(weight, quality));
            min = Math.min(min, quality);
            max = Math.max(max, quality);
        }
        this.cardPullWeight = tmpList;
        this.qualityRange = new IntRange(min, max);
    }

    public WeightConfig<ElementalBondsCardWeight> getCardPullWeight() {
        return cardPullWeight;
    }

    public void parseScore(String score) {
        this.score = StringUtils.stringToLongList(score, "\\|");
    }

    public int getScoreRate() {
        return scoreRate;
    }
}
